home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Papers / C++ Exceptions / µShell / Toolbox / AppleEventManager.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-15  |  1.4 KB  |  64 lines  |  [TEXT/CWIE]

  1. #ifndef __APPLEEVENTMANAGER__
  2. #define __APPLEEVENTMANAGER__
  3. #pragma once
  4.  
  5. #include "Module.h"
  6. #include "EventFilter.h"
  7.  
  8. #include <AppleEvents.h>
  9.  
  10. enum
  11. {
  12.     kAEFutureReply = 0
  13. };
  14.  
  15. //--------------------------------------------------------------------------------
  16.  
  17. class AppleEventManager : public TModule, public EventFilter
  18. {
  19.     DeclareClass2Base(AppleEventManager, TModule, EventFilter);
  20.  
  21. protected:
  22.     static AppleEventManager*    gAppleEventManager;
  23.     
  24. public:
  25.     static AppleEventManager&    GetAppleEventManager();
  26.  
  27.     // TModule overrides
  28.     AppleEventManager();
  29.     virtual ~AppleEventManager();
  30.     virtual bool    Validate();
  31.     virtual void    Initialize(void);
  32.     virtual void    Finalize(void);
  33.  
  34.     // EventFilter overrides
  35.     virtual bool    FilterEvent(ToolboxEvent& evt);
  36.  
  37.     static void                SendAppleEvent(
  38.         const AppleEvent&            theAppleEvent,
  39.         AppleEvent*                    reply,
  40.         long                        timeOutInTicks    = kAEDefaultTimeout,
  41.         long                        maxWaitTime        = kNoTimeOut,
  42.         AESendMode                    sendMode        = kAEFutureReply,
  43.         AESendPriority                 sendPriority    = kAENormalPriority);
  44. };
  45.  
  46. //--------------------------------------------------------------------------------
  47.  
  48. #if !qDebug
  49.  
  50. AppleEventManager::AppleEventManager()
  51. {
  52.     gAppleEventManager = this;
  53. }
  54.  
  55. inline AppleEventManager& AppleEventManager::GetAppleEventManager()
  56. {
  57.     return *gAppleEventManager;
  58. }
  59.  
  60. #endif
  61.  
  62. //--------------------------------------------------------------------------------
  63.  
  64. #endif __APPLEEVENTMANAGER__